import { ChunkLib } from "./ChunkLib";

const SnowShader = {
    uniforms: {
        'tDiffuse': { value: null },
        'iResolution': { value: null },
        'time': { value: 0 },
    },

    vertexShader: /* glsl */`

        varying highp vec2 vUv;

            void main() {

                vUv = uv;
                gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

        }`,
    fragmentShader: `
         uniform sampler2D tDiffuse;
         varying highp vec2 vUv;
         uniform float time;
         uniform vec2 iResolution;         
         ${ChunkLib.snow_pars_fragment}
         void main(void){
             vec2 uv = gl_FragCoord.xy/iResolution.xy;
             vec3 finalColor=vec3(0);
             //float c=smoothstep(1.,0.3,clamp(uv.y*.3+.8,0.,.75));
             float c = 0.0;
             // c+=snow(uv,30.)*.0;
             // c+=snow(uv,20.)*.0;
             // c+=snow(uv,15.)*.0;
             c+=snow(uv,10.);
             c+=snow(uv,8.);
             c+=snow(uv,6.);
             // c+=snow(uv,5.);
             finalColor=(vec3(c)); //屏幕上雪的颜色
             gl_FragColor = mix(vec4(texture2D(tDiffuse,vUv).rgb,1.0), vec4(finalColor,1), 0.5);  //将雪和三维场景融合
             //gl_FragColor = vec4(finalColor,1);
         }
        `
};

export { SnowShader };